package com.jereh.topnews.demo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;

import com.jereh.topnews.R;

public class ActionBarActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_action_bar);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater=getMenuInflater();
        inflater.inflate(R.menu.action_bar_demo,menu);
        return super.onCreateOptionsMenu(menu);
    }

    public void onMenuBarClick(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.refresh:
                Toast.makeText(ActionBarActivity.this, "刷新成功", Toast.LENGTH_SHORT).show();
                break;
            case R.id.review:
                Toast.makeText(ActionBarActivity.this, "重新查看成功", Toast.LENGTH_SHORT).show();
                break;
            case R.id.confirm:
                Toast.makeText(ActionBarActivity.this, "删除成功", Toast.LENGTH_SHORT).show();
                break;
            case R.id.cancel:
                Toast.makeText(ActionBarActivity.this, "取消删除", Toast.LENGTH_SHORT).show();
                break;
        }
    }
}
